import request from '@/utils/request'
import type { Response } from '@/utils/type'
import type { MenuTree } from '@/api/back-management/menu/interface'

export interface loginParams {
  loginName: string
  loginPassword: string
}

export interface UserDataResp {
  token: string
  userName: string
  refId: string
  roleId: string
  roleLevel: string
  roleName: string
  moduleTree?: MenuTree[] | undefined
}

/**
 * 全部社区管辖边界
 *
 * @param {loginParams} params 登录参数
 */
export const login = (params: loginParams): Promise<Response<UserDataResp>> => {
  return request('/user/user/login', {
    method: 'POST',
    params,
  })
}

/**
 * 退出登录
 */
export const logout = () => {
  return request('/user/user/logout', {
    method: 'POST',
  })
}
